package main

import (
	"fmt"
	"os"
	"time"
)

func main() {
	directory := "E:\\application\\go_learning\\test\\test"
	go func() {
		for {
			// 检查目录是否存在
			if _, err := os.Stat(directory); err == nil {
				// 目录存在，执行命令
				fmt.Println("Directory exists, executing command...")

				// 退出程序
				fmt.Println("Exiting...")
				return
			} else if os.IsNotExist(err) {
				// 目录不存在，等待一段时间后继续检查
				fmt.Println("Directory does not exist, waiting to create...")
				if err := os.Mkdir(directory, 0755); err != nil {
					fmt.Println("创建目录失败:", err)
					return
				}
			}
			fmt.Println("循环")
		}
	}()

	fmt.Println("Doing other things")

	time.Sleep(10 * time.Minute)
}
